package xyc.sjxy.common;

import lombok.Data;

@Data
public class Result {
    private int code;
    private String message;

    private boolean flag;

    private Object data;


    public static  Result builder(Object data){
        Result r = new Result();
        if(data!=null){
            r.setData(data);
        }
        return r;
    }
    public static Result builder(Object data,int code,String message, boolean flag){
        Result r = builder(data);
        r.setCode(code);
        r.setMessage(message);
        r.setFlag(flag);
        return r;
    }
    /*public static builder(Object data, ResultCodeEnum resultCodeEnum) {
        R<T> r = builder(data);
        r.setCode(resultCodeEnum.getCode());
        r.setMessage(resultCodeEnum.getMessage());
        return r;
    }
*/
    public static Result ok(Object data ) {
        Result r = builder(data,0, "成功",true);
        return r;
    }

    public static Result fail(Object data ) {
        Result r = builder(data,1, "失败",false);
        return r;
    }
}
